<template>
	<view class="container">
		<!-- 消息区域 -->
		<view class="chat-messages" ref="messages">
			<view class="message-item other">
				<view class="avatar">
					<img src="@/static/img/dyzj.png" alt="头像">
				</view>
				<view class="message-content">
					<view class="message-bubble">亲,有什么可以帮助您?</view>
				</view>
			</view>

			<view class="message-item self">
				<view class="avatar">
					<img src="@/static/img/dyzj.png" alt="我的头像">
				</view>
				<view class="message-content">
					<view class="message-bubble">您好！我想咨询您一个问题</view>
				</view>
			</view>
		</view>

		<!-- 底部输入区域 -->
		<view class="chat-input-area">
			<u-search :showAction="true" placeholder="" actionText="发送" v-model="keyword"></u-search>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyword: '遥看瀑布挂前川'
			}
		},
		methods: {

		}
	}
</script>

<style scoped lang="less">
	view{
		box-sizing: border-box;
	}
	.container {
		display: flex;
		flex-direction: column;
		height: calc(100vh - 44px);
		background-color: #EDEDED;
	}

	/* 消息区域 */
	.chat-messages {
		flex: 1;
		overflow-y: auto;
		padding: 32rpx;
		display: flex;
		flex-direction: column;
	}

	.message-item {
		display: flex;
		margin-bottom: 28rpx;
		gap: 30rpx;
		
	}

	.message-item.self {
		flex-direction: row-reverse;
	}

	.avatar {
		width: 84rpx;
		height: 84rpx;
		border-radius: 50%;
		overflow: hidden;
		img {
			width: 100%;
			height: 100%;
			object-fit: cover;
		}
	}

	.message-content {
		max-width: 70%;
		.message-bubble {
			padding: 20rpx;
			border-radius: 8rpx;
			position: relative;
			font-size: 28rpx;
		}
	}

	

	.message-item.other .message-bubble {
		color: #42494F;
		background-color: #C4C4C4;
	}
	.message-item.other .message-bubble::before {
		content: '';
		position: absolute;
		top: 28rpx;
		left: -10rpx;
		width: 0;
		height: 0;
		border-style: solid;
		border-width: 0 20rpx 20rpx 0;
		border-color: transparent #C4C4C4 transparent transparent;
		transform: rotate(-135deg);
	}

	.message-item.self .message-bubble {
		color: #FFFFFF;
		background-color: #3D7CFD;
	}
	.message-item.self .message-bubble::before {
		content: '';
		position: absolute;
		top: 28rpx;
		right: -10rpx;
		width: 0;
		height: 0;
		border-style: solid;
		border-width: 0 20rpx 20rpx 0;
		border-color: transparent #3D7CFD transparent transparent;
		transform: rotate(45deg);
	}

	/* 底部输入区域 */
	.chat-input-area {
		background-color: #F5F5F5;
		padding: 10px 15px;
		display: flex;
		align-items: center;
		border-top: 1px solid #DDD;
	}

</style>